trigger POShare on Purchase_Object__c (after insert,after update) {
   List<Purchase_Object__c> polist = new List<Purchase_Object__c>();
   List<Purchase_Object__Share> poshare = new List<Purchase_Object__Share>();
 Purchase_Object__Share UOrGShare = new Purchase_Object__Share();
    Set<Id> setAccId = new Set<Id>();
   for(Purchase_Object__c po : polist){
     setAccId.add(po.Account__r.id);
     UOrGShare.ParentId = po.Id;
     poshare.add(UOrGShare);
     System.debug('setaccid' + setAccId);
   }
 List<AccountShare> UOrGID = [Select UserOrGroupId,AccountAccessLevel from AccountShare where AccountId = :setAccId]; 
 for(Purchase_Object__Share pos : poshare){
    
    
    UOrGShare.UserOrGroupId = UOrGID[0].UserOrGroupId;
    UOrGShare.AccessLevel =  UOrGID[1].AccountAccessLevel;
    poshare.add(UOrGShare);
    Database.SaveResult[] lsr = Database.insert(poshare,false);
     }
  }